<%@page import="java.util.List"%>
<%@page import="com.aptech.model.realEstateInfo"%>
<%
            com.aptech.DAO.realEstateDAO objRealEstateDAO1 = new com.aptech.DAO.realEstateDAO();
            java.util.ArrayList<com.aptech.model.realEstateInfo> listrealEstateInfo;
            listrealEstateInfo = objRealEstateDAO1.getAllRealEstate();
            int pageno = 0;

%>
<div id="realEstateInfor">
            <div id="mn_realEstateInfor_header_left"></div>
            <div id="mn_realEstateInfor_header_center"></div>
            <div id="mn_realEstateInfor_header_right"></div>

            <!--				<div id="mn_houseInfo_content_left"></div> -->
            <div class="clear"></div><!--End .clear-->
            <div class="mn_realEstateInfor_content_center">

            <%
                if(!listrealEstateInfo.isEmpty()){
                    int intPage = 1;
                    List<realEstateInfo> subListRealEstateInfo;
                    int totalPage = 0;
                    if(listrealEstateInfo.size() % 10 != 0){
                        if(listrealEstateInfo.size() > 10){
                            totalPage = (listrealEstateInfo.size() / 10) + 1;
                        }else{
                            totalPage = listrealEstateInfo.size() / 10;
                        }
                    }
                    try{
                        intPage = Integer.parseInt(request.getParameter("pageno"));
                    }catch(NumberFormatException ex){
                        intPage = 1;
                    }
                    if (intPage == 1 && totalPage > 1) {
                      subListRealEstateInfo = listrealEstateInfo.subList((intPage - 1) * 10, (intPage * 10));
                    } else if (intPage == 1 && totalPage == 1) {
                        subListRealEstateInfo = listrealEstateInfo.subList(((intPage - 1) * 10), listrealEstateInfo.size());
                    } else if (intPage < totalPage) {
                        subListRealEstateInfo = listrealEstateInfo.subList(((intPage - 1) * 10), (intPage * 10));
                    } else {
                        subListRealEstateInfo = listrealEstateInfo.subList(((intPage - 1) * 10), listrealEstateInfo.size());
                    }
                    for (realEstateInfo realEstate : subListRealEstateInfo) {

                if (intPage <= 1) {
                    pageno = subListRealEstateInfo.indexOf(realEstate);
                } else {
                    pageno = ((intPage - 1) * 10) + subListRealEstateInfo.indexOf(realEstate);
                }
                //body cho vao day


            %>
            <div class="realEstateTitle"><img src="Imgs1/icon_nha.png" /> <a href="realEstateDetail.jsp?realEstateID=<%=realEstate.getRealEstateID() %>"><%=realEstate.getRealEstateTitle() %> </a></div>
                <div class="startDate">post date:<%=realEstate.getStartDate()%></div>
                <div class="realEstateImage"><img src="Imgs/realEstate_Imgs/<%= realEstate.getRealEstateImage() %>" width="100" height="100" /></div>
                <div class="realEstateDescription"><%=realEstate.getDescription() %>...<a href="realEstateDetail.jsp?realEstateID=<%=realEstate.getRealEstateID() %>">view details</a></div>
                <div class="footerInfo"></div>
                <% } %>
                <div class="PhanTrang">
                    <page:phantrang total="<%=listrealEstateInfo.size()%>" cursor=" ${param.pageno}" />
                </div>
            </div>
                <%
                }
                %>
            <!--				<div id="mn_houseInfo_content_right"></div> -->
            <div class="clear"></div><!--End .clear-->
            <div id="mn_realEstateInfor_footer_left"></div>
            <div id="mn_realEstateInfor_footer_center"></div>
            <div id="mn_realEstateInfor_footer_right"></div>
        </div><!--End #realEstateInfor-->